package study.day7;

import java.io.FileWriter;
import java.io.IOException;

public class T5 {
    //字符流写入文件
    public static void main(String[] args) {
        FileWriter fw=null;
        try {
            fw=new FileWriter("C:\\Users\\DELL\\IdeaProjects\\file\\3.txt");
            //写入数据
            String word="我是中国人";
            fw.write(word);
            fw.flush();
            System.out.println("写入成功");
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
